package day06;
//输入shapefactory补齐
import static day06.ShapeFactory.*;
public class TestShape {
	public static void main(String[] args) {
		//创建业务类对象
		ShapeService ss = new ShapeService();
		//提供需要计算的图形(面向父类编程--编译时类型写成父类)
		//Shape s = new Circle(3);
		//Shape s = new Rect(2,3);
		//Shape s = new Square(4);
		//利用工厂模式创建子类对象,静态方法直接用不需要newz
		//Shape s =ShapeFactory.getShape(ShapeFactory.CIRCLE);
		//Shape s =ShapeFactory.getShape(CIRCLE);
		//使用静态导入import static day06.ShapeFactory.*;  简化得到如下结果
		Shape s =  getShape(SQUARE);
		
	if (s instanceof Circle) {
		Circle circle = (Circle) s;
		circle.setR(3);
		//调用业务类的相关方法
	 System.out.println(ss.getArea(s));
	}else if(s instanceof Square) {
	Square square =(Square) s;
	square.setL(5);
	 System.out.println(ss.getArea(s));
	}
	}
	
}
